//
//  LYLAFNetWorking.m
//  TheLCNews
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 LCandLYL. All rights reserved.
//

#import "LYLAFNetWorking.h"

@implementation LYLAFNetWorking

+ (void)GETURLByString:(NSString *)string AFData:(AFNData)block
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html",@"text/plain", nil];
    
    // 数据解析
    [manager GET:string parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        block(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error == %@", error);
    }];
}

+ (void)POSTURLString:(NSString *)string bodyByDic:(NSDictionary *)dic AfData:(AFNData)block
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
// jiexi
[manager POST:string parameters:dic success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
    block(responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    NSLog(@" error  =====%@", error);
}];

}
@end
